﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp.智能枚举;

/// <summary>
/// 信用卡
/// </summary>
public abstract class CreditCard : Enumeration<CreditCard>
{
    public static readonly CreditCard Gold = new GoldCreditCard();
    public static readonly CreditCard Silver = new SilverCreditCard();
    public static readonly CreditCard Standard = new StandardCreditCard();
    public static readonly CreditCard None = new NoneCreditCard();

    private CreditCard(int value, string name) : base(value, name)
    {
    }

    /// <summary>
    /// 折扣
    /// </summary>
    public abstract double Discount { get; }

    /// <summary>
    /// 金卡
    /// </summary>
    private sealed class GoldCreditCard : CreditCard
    {
        public GoldCreditCard() : base(3, nameof(Gold))
        {
        }

        public override double Discount => 0.2;
    }

    private sealed class SilverCreditCard : CreditCard
    {
        public SilverCreditCard() : base(2, nameof(Silver))
        {
        }

        public override double Discount => 0.1;
    }

    /// <summary>
    /// 标准
    /// </summary>
    private sealed class StandardCreditCard : CreditCard
    {
        public StandardCreditCard() : base(1, nameof(Standard))
        {
        }

        public override double Discount => 0.05;
    }

    /// <summary>
    /// 无
    /// </summary>
    private sealed class NoneCreditCard : CreditCard
    {
        public NoneCreditCard() : base(0, nameof(None))
        {
        }

        public override double Discount => 0;
    }
}

